home *** CD-ROM | disk | FTP | other *** search
- # Source Generated with Decompyle++
- # File: in.pyo (Python 2.5)
-
- import wx
- from time import time
- from xml.sax.saxutils import escape
- from gui.textutil import default_font
- from util import Point2HTMLSize, linkify
- from gui.skin import get as skin_get
- separatorshort = u'<br><wxp module="gui.infobox.htmlbitmaps" class="BitmapFromSkin" width="99%" height="-1"><param name="key" value="infobox.shortseparatorimage"><param name="padding" value="(3,3)"></wxp>'
- separatorlong = u'<br><wxp module="gui.infobox.htmlbitmaps" class="BitmapFromSkin" width="100%" height="-1"><param name="key" value="infobox.longseparatorimage"><param name="padding" value="(0,4)"></wxp>'
- JABBER_SERVICES = [
- u'jabber',
- u'gtalk',
- u'digsby']
- from common.protocolmeta import protocols
- titlespace = u' '
-
- def ColorHTML(color):
- if color[0:2].lower() == '0x':
- return ''.join('#', color[2:8])
-
- return color
-
-
- def GenBitmapHTML(key, width, height):
- return u''.join([
- u'<wxp module="gui.infobox.htmlbitmaps" class="BitmapFromSkin" width ="',
- str(width),
- u'" height="',
- str(height),
- u'"><param name="key" value="',
- key,
- u'"></wxp>'])
-
-
- def GenBuddyIconHTML(contid):
- return u''.join([
- u'<wxp module="gui.infobox.htmlbitmaps" class="BuddyIcon"><param name="contid" value="',
- contid,
- u'"></wxp>'])
-
-
- def FontTagify(string, fonttype):
- font = skin_get('infobox.fonts.%s' % fonttype, default_font())
- color = skin_get('infobox.fontcolors.%s' % fonttype, wx.BLACK).GetAsString(wx.C2S_HTML_SYNTAX)
- if isinstance(string, str):
-
- try:
- string = string.decode('fuzzy')
- except UnicodeDecodeError:
- e = None
- log.info("Couldn't put %r into a font tag- decode failed with error %r", string, e)
- return ''
- except:
- None<EXCEPTION MATCH>UnicodeDecodeError
-
-
- None<EXCEPTION MATCH>UnicodeDecodeError
- tag = None([
- None,
- None,
- None,
- None,
- None,
- u''.join,
- '<font face="',
- font.FaceName,
- '" size="',
- str(Point2HTMLSize(font.PointSize)),
- '" color="',
- color,
- '">' if font.Weight == wx.BOLD else '' if font.Style == wx.ITALIC else '' if font.Underlined else '',
- string if font.Underlined else '' if font.Style == wx.ITALIC else '' if font.Weight == wx.BOLD else '',
- '</font>'])
- return tag
-
-
- def TitleHTML(title):
- return FontTagify(escape(title).replace('\n', '<br>'), 'title')
-
-
- def BodyHTML(text):
- return FontTagify(escape(text).replace('\n', '<br>'), 'minor')
-
-
- def List2HTML(listostuff):
- string = ''
- for stuff in listostuff:
- if isinstance(stuff, basestring):
- pass
- elif isinstance(stuff, tuple):
- pass
- elif isinstance(stuff, list):
- pass
- elif isinstance(stuff, dict):
- pass
-
- string = ''.join([
- string,
- ''])
-
- return string
-
-
- def ListProfile2HTML(listostuff):
- profile = []
- for stuff in listostuff:
- if isinstance(stuff, basestring):
- pass
- elif isinstance(stuff, dict):
- pass
-
- profile.append('')
-
- return ''.join(profile)
-
-
- def PrettyProfile2HTML(profile):
- if not profile:
- return 'No Profile'
-
- string = ''
- for key in profile.keys():
- value = profile[key]
- if value:
- if isinstance(value, int):
- string = ''.join([
- string,
- exbr(value)])
- elif isinstance(value, basestring):
- pass
- elif isinstance(value, tuple):
- pass
- elif isinstance(value, list):
- pass
- elif isinstance(value, dict):
- pass
-
- string = ''.join([
- string,
- TitleHTML(key),
- titlespace,
- '',
- '<br>'])
- continue
-
- return string
-
-
- def exbr(height):
- return ''.join([
- '<table cellpadding=',
- str(height),
- ' cellspacing=0 border=0><tr><td></td></tr></table>'])
-
-
- def ProfileHTML(profile):
- if isinstance(profile, dict):
- profile = PrettyProfile2HTML(profile)
- elif isinstance(profile, list):
- profile = ListProfile2HTML(profile)
- else:
- profile = u'<TABLE width="100%" cellpadding="0" cellspacing="0" border="0"><tr><td>No Profile</td></tr></table>'
- return u''.join([
- u'</TD></TR></TABLE>',
- u'<TABLE WIDTH=100% cellpadding=0 border=0><TR><TD>',
- separatorlong,
- profile])
-
-
- def ImageHTML(**attrs):
- if not attrs:
- return ''
-
- if 'src' in attrs:
- key = 'url'
- cls = 'BitmapFromWeb'
- data = attrs['src']
- elif 'data' in attrs:
- key = 'data'
- cls = 'BitmapFromData'
- b64encode = b64encode
- import base64
- data = b64encode(attrs['data'])
-
- w = attrs.get('width', -1)
- h = attrs.get('height', -1)
- href = attrs['href']
- return '<wxp module="gui.infobox.htmlbitmaps" class="%(cls)s" width="%(w)d" height="%(h)d"><param name="%(key)s" value="%(data)s"><param name="href" value="%(href)s"></wxp>' % locals()
-
-
- def LinkHTML(url, text):
- if isinstance(text, basestring):
- pass
- elif isinstance(text, dict):
- pass
-
- return u''.join([
- u'<a href=',
- url,
- u'>',
- FontTagify('', 'link'),
- u'</a>'])
-
-
- def GenTimedString(timeinsecs):
- secs = int(time()) - timeinsecs
- (mins, secs) = divmod(secs, 60)
- (hours, mins) = divmod(mins, 60)
- (days, hours) = divmod(hours, 24)
- if not days > 0 and hours > 0 or mins > 0:
- return u'<1m'
-
- timeStr = u''
- if days > 0:
- timeStr += str(int(days)) + u'd '
-
- if hours > 0:
- timeStr += str(int(hours)) + u'h '
-
- if mins > 0:
- timeStr += str(int(mins)) + u'm'
-
- return timeStr
-
-
- def JabberStatusMagic(contact):
- string = u''.join([
- TitleHTML(u'Subscription:'),
- titlespace,
- BodyHTML(contact.protocol.roster.get_item_by_jid(contact.id).subscription.capitalize())])
- for r in contact.resources.values():
- if not r.jid.resource:
- pass
- string = u''.join([
- string,
- separatorshort,
- TitleHTML(u'Resource:'),
- titlespace,
- BodyHTML(u''.join([
- '',
- u' (',
- str(r.priority),
- u')']))])
- string = u''.join([
- string,
- u'<br>',
- TitleHTML(u'Status:'),
- titlespace,
- BodyHTML(r.sightly_status)])
- if r.status_message:
- string = u''.join([
- string,
- u'<br>',
- BodyHTML(r.status_message)])
- continue
-
- return string
-
-
- def GetInfo(contact, showprofile = False, showhide = True):
- wx.GetApp().StupidContactHack = contact
- constanttop = u''.join([
- u'<body><TABLE WIDTH=100% cellpadding=0 border=0><TR><TD valign=top>'])
- constantmiddle = u'</TD><TD width=64 valign=top align=center>'
- constantbottom = u'</TD></TR></TABLE></body>'
- s = contact.service
- if s == 'digsby' and getattr(contact, 'iswidget', False):
- s = 'widget'
-
- servico = u''.join([
- u'<TABLE WIDTH=100% cellpadding=0 cellspacing=0 border=0 VALIGN=CENTER ALIGN=LEFT><TR><TD valign=center>',
- GenBitmapHTML(u'serviceicons.' + s, 16, 16),
- u'</TD><TD> </TD>'])
- displayname = contact.alias
- name = u''.join([
- u'<TD WIDTH=100%>',
- FontTagify(escape(displayname), 'header'),
- u'</TD></TR></TABLE><TABLE WIDTH=100% cellpadding=1 cellspacing=0 border=0><TD></TD></TABLE>'])
- if s == 'widget':
- ip = u''.join([
- TitleHTML(u'IP Address:'),
- titlespace,
- BodyHTML(contact.ip)])
- time = u''.join([
- TitleHTML(u'Time on Page:'),
- titlespace,
- BodyHTML(GenTimedString(contact.online_time))])
- html = u''.join([
- constanttop,
- servico,
- name,
- u'<br>',
- ip,
- u'<br>',
- time,
- constantbottom])
- return html
-
- username = contact.nice_name
- if username != displayname:
- name = u''.join([
- name,
- '<br>',
- TitleHTML(protocols[contact.service].username_desc) + u':',
- titlespace,
- BodyHTML(username)])
-
- profile = None if showprofile else u''
- if contact.service in ('icq', 'aim') and contact.online_time:
- times = u''.join([
- TitleHTML(u'Online:'),
- titlespace,
- BodyHTML(GenTimedString(contact.online_time))])
- else:
- times = u''
- if contact.service in ('icq', 'aim', 'yahoo'):
- if contact.idle and contact.idle is not True:
- pass
- elif times:
- pass
-
- times = None([
- u''.join,
- u''])
-
- if contact.status_orb == 'unknown' or contact.service not in JABBER_SERVICES:
- status = u''.join([
- TitleHTML(u'Status:'),
- titlespace,
- BodyHTML(contact.sightly_status)])
- else:
- status = JabberStatusMagic(contact)
- if contact.status == u'away' and contact.idle:
- status = u''.join([
- status,
- BodyHTML(u' + Idle')])
-
- statusmsg = getattr(contact, '_infobox_status_message', contact.status_message)
- if not statusmsg or contact.service in JABBER_SERVICES:
- statusmsg = ''
- elif contact.service not in ('aim', 'icq'):
- statusmsg = BodyHTML(statusmsg)
-
- statusmsg = u''.join((separatorshort, statusmsg))
- icon = None([
- None,
- ''.join,
- constantmiddle,
- GenBuddyIconHTML(contact.idstr())(u'<br><table cellpadding="1" cellspacing="0" border="0"><tr><td></td></tr></table>', LinkHTML if showhide else '')])
- html = u''.join([
- constanttop,
- servico,
- name,
- u'<br>',
- times,
- status,
- statusmsg,
- icon,
- profile,
- constantbottom])
- return linkify(html)
-
-